package cn.scw.project.system.controller;

import cn.scw.common.constant.SysConsts;
import cn.scw.framework.web.controller.BaseController;
import cn.scw.framework.web.domain.AjaxResult;
import cn.scw.framework.web.page.TableDataInfo;
import cn.scw.project.system.domain.SysUserBrokerage;
import cn.scw.project.system.service.ISysUserBrokerageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 每日佣金Controller
 *
 * @author api
 * @date 2020-05-20
 */
@Api(tags = "佣金")
@RestController
@RequestMapping(SysConsts.CONTEXT_PATH+"/system/brokerage")
public class SysUserBrokerageController extends BaseController {
    @Autowired
    private ISysUserBrokerageService sysUserBrokerageService;

    /**
     * 查询每日佣金列表
     */
    @PreAuthorize("@ss.hasPermi('system:brokerage:list')")
    @GetMapping("/list")
    public TableDataInfo list() {
        startPage();
        List<SysUserBrokerage> list = sysUserBrokerageService.selectSysUserBrokerageList();
        return getDataTable(list);
    }

    @ApiOperation("查询今日佣金")
    @GetMapping("/wx/toDay")
    public AjaxResult wxToDay() {
        SysUserBrokerage brokerage = sysUserBrokerageService.selectSysUserBrokerageByToDay();
        return AjaxResult.success(brokerage);
    }

    @ApiOperation("获取每日佣金详细信息")
    @PreAuthorize("@ss.hasPermi('system:brokerage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sysUserBrokerageService.selectSysUserBrokerageById(id));
    }

//    /**
//     * 新增每日佣金
//     */
//    @PreAuthorize("@ss.hasPermi('system:brokerage:add')")
//    @Log(title = "每日佣金", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody SysUserBrokerage sysUserBrokerage) {
//        return toAjax(sysUserBrokerageService.insertSysUserBrokerage(sysUserBrokerage));
//    }
//
//    /**
//     * 修改每日佣金
//     */
//    @PreAuthorize("@ss.hasPermi('system:brokerage:edit')")
//    @Log(title = "每日佣金", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody SysUserBrokerage sysUserBrokerage) {
//        return toAjax(sysUserBrokerageService.updateSysUserBrokerage(sysUserBrokerage));
//    }
//
//    /**
//     * 删除每日佣金
//     */
//    @PreAuthorize("@ss.hasPermi('system:brokerage:remove')")
//    @Log(title = "每日佣金", businessType = BusinessType.DELETE)
//    @DeleteMapping("/{ids}")
//    public AjaxResult remove(@PathVariable Long[] ids) {
//        return toAjax(sysUserBrokerageService.deleteSysUserBrokerageByIds(ids));
//    }
}
